Encoding quantified wands using MWSFs#985
Open
marcoeilers wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces the encoding of magic wand snapshots for quantified wands as a pair of snaps with a function from snap to snap. The encoding was already updated for non-quantified wands in #836, which fixes an unsoundness when using the same wand in multiple
applying-expressions.There is an existing implementation that also changes the encoding for quantified wands in #849; this PR is intended to replace that existing PR, and it takes some inspiration from it and uses the tests provided by that PR.
The key problem to be solved is that, when working with quantified permissions, Silicon emits additional definitions (e.g. of snapshot maps
sm), that can summarize values coming from the left hand side of the wand. These definitions become part of the definition of the wand's snapshot function. So we can get a definition likeWhen the same wand is applied multiple times with different snapshots, that can lead to contradictions, because
lookup(sm, r)is assumed to be equal to bothe(lhs1)ande(lhs2), which might be different. The existing PR #849 essentially tried to fix this problem retroactively, rewriting assumed declarations after the fact. This one instead uses (a slightly extended version of) Silicon's existing functionality for extending new declarations like snapshot maps with a number of quantified variables stored in the state, so we get the (unproblematic) versionUsing the existing idea of parameterizing declarations with quantified variables is more in line with the way the existing code works, and minimizes changes, which should enable us to merge some other upcoming wand-related changes more easily.
We do, however, add a new field
packagingWandSnapshotsto the state instead of using the existingquantifiedVariablesfield because we want to treat them slightly differently and include them only when absolutely needed.